package taskit.datastructures;

import taskit.storage.Data;

//@author A0087072A
public abstract class Command implements ITaskItObject {
	Task task;
	Data data;
	int testResult = RETURN_FAILURE;

	
	public void execute() throws Exception {
		execute(false);
	}
	
	protected abstract void execute(boolean test) throws Exception;
	
	public boolean _test_execute() {
		try {
			execute(true);
			if (task instanceof Floating) {
				if(testResult != CMD_ADD_TODO) {
					return false;
				}
			} else if (task instanceof Schedule) {
				if(testResult != CMD_ADD_EVENT) {
					return false;
				}
			} else if (task instanceof Deadline) {
				if(testResult != CMD_ADD_DEADLINE) {
					return false;
				}
			}
			return true;
		} catch (Exception anyEx) {
			return false;
		}
	}
	
	public abstract Command reverse();
}
